import com.googlecode.lightest.studio.TestSuite

class TestSuiteController {

    def scaffold = TestSuite
    
    def search = {
        def results = TestSuite.createCriteria().list {
            and {
                if (params.q) {
                    or {
                        ilike ('name', '%' + params.q + '%')
                        ilike ('description', '%' + params.q + '%')
                    }
                }
                if (! params.includeTemporary) {
                    eq ('temporary', false)
                }
            }
            maxResults (20)
            order ('name', 'asc')
        }
        
        return [ results: results ]
    }
}
